package com.hnichr.crm.biz.followup.service.impl;

import com.hnichr.crm.common.followup.entity.CrmFollowupRecord;
import com.hnichr.crm.common.followup.service.ICrmFollowupRecordService;
import com.mxpioframework.jpa.JpaUtil;
import com.mxpioframework.jpa.initiator.JpaUtilAble;
import com.mxpioframework.jpa.query.Criteria;
import org.springframework.context.ApplicationContext;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 跟进记录Service业务层处理
 *
 * @author Cheng
 * @date 2022-11-24
 */
@Service
public class CrmFollowupRecordServiceImpl implements ICrmFollowupRecordService, JpaUtilAble {
    @Override
    public void afterPropertiesSet(ApplicationContext applicationContext) {

    }

    @Override
    @Transactional(readOnly = true)
    public Page<CrmFollowupRecord> page(Criteria criteria, Pageable pageable) {
        return JpaUtil.linq(CrmFollowupRecord.class).where(criteria).paging(pageable);
    }

    @Override
    @Transactional(readOnly = true)
    public CrmFollowupRecord getById(String id) {
        return JpaUtil.linq(CrmFollowupRecord.class).idEqual(id).findOne();
    }

    @Override
    @Transactional(readOnly = false)
    public void save(CrmFollowupRecord crmFollowupRecord) {
        JpaUtil.save(crmFollowupRecord);
    }

    @Override
    @Transactional(readOnly = false)
    public void update(CrmFollowupRecord crmFollowupRecord) {
        JpaUtil.update(crmFollowupRecord);
    }

    @Override
    @Transactional(readOnly = false)
    public int delete(String id) {
        return JpaUtil.lind(CrmFollowupRecord.class).equal("id", id).delete();
    }
}
